package com.example.node.utils;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreUtils {
    private static final String SP_NAME="config";
    public static void putString(Context mContext,String key,String values){
        SharedPreferences sp=mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.putString(key,values);
        editor.apply();
    }
    public static String getString(Context mContext,String key,String defValues){
        SharedPreferences sp=mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);
        return sp.getString(key,defValues);
    }

    public static void putInt(Context mContext,String key,int values){
        SharedPreferences sp=mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.putInt(key,values);
        editor.apply();
    }
    public static int getInt(Context mContext,String key,int defValues){
        SharedPreferences sp=mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);
        return sp.getInt(key,defValues);
    }

    public static void putBoolean(Context mContext,String key,boolean values){
        SharedPreferences sp=mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.putBoolean(key,values);
        editor.apply();
    }
    public static boolean getBoolean(Context mContext,String key,boolean defValues){
        SharedPreferences sp=mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);
        return sp.getBoolean(key,defValues);
    }

    public static void deleKey(Context mContext,String key){
        SharedPreferences sp=mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.remove(key);
        editor.apply();
    }

    public static void deleAll(Context mContext){
        SharedPreferences sp=mContext.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE);
        SharedPreferences.Editor editor=sp.edit();
        editor.clear();
        editor.apply();
    }
}
